package com.sayimo.maker.mall;


import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sayimo.framework.exception.ServiceException;
import com.sayimo.maker.commons.Constant;
import com.sayimo.maker.mall.goods.service.EnterpriseCommentService;
import com.sayimo.maker.mall.goods.service.GoodsClassInterfaceService;
import com.sayimo.maker.mall.goods.service.GoodsCollectionService;
import com.sayimo.maker.mall.goods.service.GoodsCommentIterfaceService;
import com.sayimo.maker.mall.goods.service.GoodsIndexService;
import com.sayimo.maker.mall.goods.service.GoodsListInterfaceService;
import com.sayimo.maker.mall.goods.service.GoodsNormsInfoInterfaceSerice;
import com.sayimo.maker.mall.goods.service.GoodsNormsValueStockInterfaceService;
import com.sayimo.maker.mall.goods.service.ShoppingCartService;
import com.sayimo.maker.mall.search.service.SearchService;
import com.sayimo.maker.mall.search.vo.SearchInsertParam;





@Controller
@RequestMapping("/goods")
public class GoodsController {
	
	private static Log logger = LogFactory.getLog(GoodsController.class);
	
	@Resource(name="goodsCollectionService")
	private GoodsCollectionService goodsCollectionService;
	@Resource(name="goodsIndexService")
	private GoodsIndexService goodsIndexService;
	@Resource(name="shoppingCartServiceImpl")
	private ShoppingCartService shoppingCartServiceImpl;
	@Autowired
	private GoodsNormsInfoInterfaceSerice goodsNormsInfoInterfaceSerice;
	@Autowired
	private GoodsClassInterfaceService goodsClassInterfaceService;
	@Autowired 
	private GoodsListInterfaceService goodsListInterfaceService;
	@Autowired
	private GoodsNormsValueStockInterfaceService goodsNormsValuesInterfaceService;
	@Autowired
	private GoodsCommentIterfaceService goodsCommentIterfaceService;
	@Autowired
	private EnterpriseCommentService enterpriseCommentService;
	@Resource(name="searchService")
	private SearchService searchService;
	
	/**
	 * 
	* @Title: addGoodsCommentOrReply 
	* @Author: 田超
	* @Date:日期：2016年12月30日  时间：上午11:25:00
	* @Description: 添加收藏
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@RequestMapping(value = "/goodscollectadd",  method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> goodsCollectAdd(HttpServletRequest request){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsCollectionService.addGoodsCollection(request);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: goodsCollectAdd 
	* @Author: 田超
	* @Date:日期：2016年12月30日  时间：上午11:38:51
	* @Description: 收藏列表
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@RequestMapping(value = "/goodscollectlist/{pageNow}/{pageSize}/{type}",  method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> goodsCollectAdd(HttpServletRequest request
			,@PathVariable("pageNow")Integer pageNow,
			@PathVariable("pageSize")Integer pageSize,@PathVariable("type")Integer type){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {	
			Integer customerId = (Integer) request.getAttribute("customerId");
			resultMap = goodsCollectionService.queryGoodsCollection(customerId,pageNow,pageSize,type);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: goodsCollectDelete 
	* @Author: 田超
	* @Date:日期：2016年12月30日  时间：上午11:49:31
	* @Description: 取消收藏
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@RequestMapping(value = "/goodscollectdelete" ,method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> goodsCollectDelete(HttpServletRequest request){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsCollectionService.deleteGoodsCollection(request);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	
	/**
	 * 
	* @Title: addShoppingCart
	* @Author: 田超
	* @Date:日期：2017年1月9日 : 上午11:37:43
	* @Description: 添加购物车
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@RequestMapping(value = "/addshoppingcart",method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> addShoppingCart(HttpServletRequest request){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = shoppingCartServiceImpl.addShoppingCart(request);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: deleteShoppingCarts
	* @Author: 田超
	* @Date:日期：2017年1月9日 : 下午2:24:28
	* @Description:删除购物车
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@RequestMapping(value = "/deleteshoppingcarts",method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> deleteShoppingCarts(HttpServletRequest request){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = shoppingCartServiceImpl.deleteShoppingCarts(request);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	
	/**
	 * 
	* @Title: getShoppingCartList
	* @Author: 田超
	* @Date:日期：2017年1月9日 : 下午4:42:38
	* @Description: 获取购物车列表
	* @return Map<String,Object>
	* @Version 1.0.0
	 */
	@RequestMapping(value = "/getshoppingcartlist/{mallType}" , method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getShoppingCartList(HttpServletRequest request,
			@PathVariable("mallType")Integer mallType){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			Integer customerId = (Integer) request.getAttribute("customerId");
			resultMap = shoppingCartServiceImpl.getShoppingCartList(customerId,mallType);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	
	/**
	 * 
	* @Title: getIndexTemplate 
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 首页模版
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getindextemplate/{identifier}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getIndexTemplate(@PathVariable("identifier") String identifier){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsIndexService.queryGoodsIndexs(identifier);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: goodsClassList 
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 查询分类列表
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/goodsclasslist" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> goodsClassList(){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsClassInterfaceService.goodsClassList();
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
			
			
			
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: goodsListOfClassId
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 根据分类ID查询商品列表
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getgoodslistbyclassid/{classId}/{pageSize}/{pageNow}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> goodsListOfClassId(@PathVariable("classId") Integer classId,
			@PathVariable("pageSize") Integer pageSize, 
			@PathVariable("pageNow") Integer pageNow,
			@RequestParam(value = "goodsName", required = false) String goodsName,
			@RequestParam(value = "sortWord", required = false) String sortWord,
			@RequestParam(value = "sortMode", required = false) String sortMode,
			@RequestParam(value = "brandId", required = false) String brandId,
			@RequestParam(value = "isStudent", required = false) String isStudent,
			@RequestParam(value = "providerId", required = false) String providerId,
			@RequestParam(value = "timestamp", required = false) String timestamp,
			@RequestParam(value = "mallType", required = false) String mallType){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			Integer _mallType=mallType==null||"".equals(mallType)?null:Integer.valueOf(mallType);
			Integer _sortWord=sortWord==null||"".equals(sortWord)?null:Integer.valueOf(sortWord);
			Integer _sortMode=sortMode==null||"".equals(sortMode)?null:Integer.valueOf(sortMode);
			Integer _brandId=brandId==null||"".equals(brandId)?null:Integer.valueOf(brandId);
			Integer _providerId=providerId==null||"".equals(providerId)?null:Integer.valueOf(providerId);
			resultMap = goodsClassInterfaceService.queryGoodsListByClassId(_mallType ,classId,pageSize,pageNow,
					goodsName, _sortWord, _sortMode, _brandId,isStudent, _providerId,timestamp);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: getBrandListByClassId
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 获取分类下品牌列表
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getbrandlistbyclassid/{classId}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getBrandListByClassId(@PathVariable("classId") Integer classId){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsClassInterfaceService.getBrandListByClassId(classId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: goodsCommentList
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 查询商品评论
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getgoodscomments/{goodsId}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> goodsCommentList(@PathVariable("goodsId") Integer goodsId,
			@RequestParam(value = "recordNum", required = false) Integer recordNum){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsCommentIterfaceService.queryGoodsComment(goodsId,recordNum);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: addGoodsCommentOrReply
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 添加商品评论或回复
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/addgoodscomments" ,method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> addGoodsCommentOrReply(HttpServletRequest request){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsCommentIterfaceService.insertGoodsCommentOrReply(request);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: goodsDetail
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 商品详情
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getgoodsinfo/{goodsId}/{normsValueId}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> goodsDetail(@PathVariable("goodsId")Integer goodsId,@PathVariable("normsValueId")Integer normsValueId,
			@RequestParam(value = "isActivity", required = false) String isActivity,
			@RequestParam(value = "identifier", required = false) String identifier,
			@RequestParam(value = "seckillTimesId", required = false) Integer seckillTimesId,
			@RequestParam(value = "customerId", required = false) Integer customerId,
			@RequestParam(value = "areaCode", required = false) String areaCode){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsListInterfaceService.updateQueryGoodsById(normsValueId, goodsId, customerId, areaCode, isActivity, identifier, seckillTimesId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: searchGoodsByName
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 首页商品搜索
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/searchgoodsbyname" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> searchGoodsByName(@RequestParam(required=false, value="mallType") String mallType,
			@RequestParam(required=false, value="goodsName") String goodsName,
			@RequestParam(required=false, value="providerId") String providerId){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsListInterfaceService.searchGoodsByName(mallType,goodsName, providerId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: changeGoodsNormsValue
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 商品详情切换规格
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/changegoodsnormsvalue/{goodsId}/{normsValueId}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> changeGoodsNormsValue(@PathVariable("goodsId")Integer goodsId,@PathVariable("normsValueId")Integer normsValueId){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsNormsValuesInterfaceService.changeGoodsNormsValue(goodsId, normsValueId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: getGoodsCount
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 首页商品统计
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getgoodscount" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getGoodsCount(){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsListInterfaceService.getGoodsCount();
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: suggestGoodsSearch
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 前端商品搜索时提示建议
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/suggestgoodssearch" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> suggestGoodsSearch(@RequestParam(required=false, value="mallType") String mallType,
			@RequestParam(required=false, value="goodsName") String goodsName,
			@RequestParam(value = "type", required = false)Integer type,
			@RequestParam(value = "classId", required = false)String classId){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsListInterfaceService.suggestGoodsSearch(mallType,goodsName, type,classId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: getAllNormsValues
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 商品详情多规格
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getallnormsvalues/{goodsId}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getAllNormsValues(@PathVariable("goodsId")Integer goodsId){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsNormsInfoInterfaceSerice.allNormsValues(goodsId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	
	/**
	 * 
	* @Title: normsInfo
	* @Author: wangyang
	* @Date:日期：2016年12月30日  
	* @Description: 选择商品规格（组合规格）
	* @return Map<String,Object>
	* @Version 2.0.0
	 */
	@RequestMapping(value = "/getnormsinfo/{goodsId}/{normsValueIds}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> normsInfo(@PathVariable("goodsId")Integer goodsId,@PathVariable("normsValueIds")String normsValueIds,
			@RequestParam(value = "isActivity", required = false) String isActivity,
			@RequestParam(value = "identifier", required = false) String identifier,
			@RequestParam(value = "seckillTimesId", required = false) Integer seckillTimesId,
			@RequestParam(value = "customerId", required = false) Integer customerId){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {			
			resultMap = goodsNormsInfoInterfaceSerice.normsInfo(goodsId, normsValueIds, isActivity, identifier, seckillTimesId, customerId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:unionShopList
	 * @Description:联盟商家列表
	 * @param classId
	 * @return
	 * @Date 2017年2月15日,上午9:50:14
	 */
	@RequestMapping(value = "/unionshoplist/{unionshopClassId}/{pageNow}/{pageSize}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> unionShopList(@PathVariable("unionshopClassId")Integer unionshopClassId,
			@PathVariable("pageNow")Integer pageNow,
			@PathVariable("pageSize")Integer pageSize,
			@RequestParam(value = "longitude", required = false) String longitude,
			@RequestParam(value = "latitude", required = false) String latitude,
			@RequestParam(value = "providerName", required = false) String providerName){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsListInterfaceService.unionShopList(unionshopClassId,longitude,latitude,pageNow,pageSize,providerName);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:unionShopById
	 * @Description:联盟商家详情
	 * @param providerId
	 * @return
	 * @Date 2017年2月18日,上午11:57:02
	 */
	@RequestMapping(value = "/unionshopbyid/{providerId}" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> unionShopById(@PathVariable("providerId")Integer providerId){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = goodsListInterfaceService.unionShopById(providerId);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:addEnterprisePointPraise
	 * @Description:商家点赞
	 * @param request
	 * @return
	 * @Date 2017年2月16日,上午11:53:52
	 */
	@RequestMapping(value = "/addenterprisepointpraise" ,method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> addEnterprisePointPraise(HttpServletRequest request){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = enterpriseCommentService.addEnterprisePointPraise(request);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:addEnterpriseComment
	 * @Description:添加商家评论
	 * @param request
	 * @return
	 * @Date 2017年2月16日,下午2:23:54
	 */
	@RequestMapping(value = "/addenterprisecomment" ,method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> addEnterpriseComment(HttpServletRequest request){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = enterpriseCommentService.addEnterpriseComment(request);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:queryEnterpriseComment
	 * @Description:查询商家评论
	 * @param providerId
	 * @param pageNow
	 * @param pageSize
	 * @return
	 * @Date 2017年2月16日,下午3:18:55
	 */
	@RequestMapping(value = "/queryenterprisecomment/{providerId}/{pageNow}/{pageSize}",  method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> queryEnterpriseComment(@PathVariable("providerId")Integer providerId,
			@PathVariable("pageNow")Integer pageNow,
			@PathVariable("pageSize")Integer pageSize,
			@RequestParam(value = "commentLevel", required = false) String commentLevel){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = enterpriseCommentService.queryEnterpriseComment(providerId,commentLevel,pageNow,pageSize);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:initSearchEngine
	 * @Description:搜索引擎初始化
	 * @param searchInsertParam
	 * @return
	 * @Date 2017年2月22日,下午2:24:51
	 */
	@RequestMapping(value = "/initsearchengine" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> initSearchEngine(SearchInsertParam searchInsertParam){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = searchService.init(searchInsertParam);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:insertSearchEngine
	 * @Description:添加商品，同时添加到搜索引擎
	 * @param searchInsertParam
	 * @return
	 * @Date 2017年2月22日,下午4:40:50
	 */
	@RequestMapping(value = "/insertsearchengine" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> insertSearchEngine(SearchInsertParam searchInsertParam){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = searchService.insertSearchEngine(searchInsertParam);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
	/**
	 * @Package com.sayimo.maker.mall
	 * @Author TANXIN
	 * @MethodName:deleteSearchEngine
	 * @Description:删除商品时，同时删除搜索引擎中对应记录
	 * @param ids
	 * @param identifier
	 * @return
	 * @Date 2017年2月22日,下午4:40:58
	 */
	@RequestMapping(value = "/deletesearchengine" ,method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> deleteSearchEngine(String ids, String identifier){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = searchService.deleteSearchEngine(ids, identifier);
		} catch (ServiceException e) {
			logger.error(e);
			e.printStackTrace();
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR_CODE,Constant.SYSTEM_ERROR);
		}
		return resultMap;
	}
}
